#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

class SpTabGraph {
private:
    vector< vector<float> > ST;
    size_t n;

    void precalc() {

        ST.resize((size_t)(log((double)n)/log(2.0)) + 1);
        size_t currLenOfArr = n;
        ST[0].resize(n);

        for(size_t i = 0; i < n; ++i)
            ST[0][i] = v[i];

        for(size_t k = 1; currLenOfArr > 1<<(k-1); ++k) {
            currLenOfArr -= 1<<(k-1);
            ST[k].resize(currLenOfArr);
            for(size_t i = 0; i < currLenOfArr; ++i) 
                ST[k][i] = min(ST[k-1][i], ST[k-1][i + (1<<(k-1))]); 
        }
    }

public:
    vector<float> v;

    explicit SpTabGraph (const vector<float>& src) {
        n = src.size();
        for (size_t i = 0; i < n; ++i)
            v.push_back(src[i]);
        (*this).precalc();
    }

    float RMQ(int i, int j) {
        int k = (int)(log((double)(j-i+1))/log(2.0));
        
        return min(ST[k][i], ST[k][j - (1<<k) + 1]);
    }


};

int main() {
    vector<float> a, ans;
    int m,n,b,e;

    scanf("%d",&n);
    a.resize(n);

    for(int i = 0; i < n;++i) {
        scanf("%f",&a[i]);
    }

    SpTabGraph SpT(a);

    scanf("%d",&m);
    ans.resize(m);

    for(int i = 0; i < m; ++i) {
        scanf("%d %d",&b,&e);
        ans[i] = SpT.RMQ(b,e - 1);
    }
        
    for(int i = 0; i < m; ++i)
        printf("%f ",ans[i]);

    return 0;
}
